import React from 'react'
import { useSelector, useDispatch } from 'react-redux'
import { add } from '../store'
export default function Count() {
  // 用于过滤诗句
  const c = useSelector((state) => {
    // state是redux中所有数据
    // console.log(state)
    return state.xxx.c // return结果就是useSelector的返回值
  })
  // 用于返回dispatch函数
  const dispatch = useDispatch()
  return (
    <div>
      <h1>{c}</h1>
      <button
        onClick={() => {
          dispatch(add(6))
        }}
      >
        +
      </button>
    </div>
  )
}
